home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume2 / x11.3 / patch2 < prev    next >
Encoding:
Text File  |  1988-11-21  |  42.2 KB  |  1,624 lines

  1. Path: uunet!wyse!mikew
  2. From: mikew@wyse.wyse.com (Mike Wexler)
  3. Newsgroups: comp.sources.x
  4. Subject: v02i016:  X11 Release 3, Patch2
  5. Message-ID: <1841@wyse.wyse.com>
  6. Date: 21 Nov 88 17:38:24 GMT
  7. Sender: news@wyse.wyse.com
  8. Organization: Wyse Technology, San Jose
  9. Lines: 1612
  10. Approved: mikew@wyse.com
  11.  
  12. Submitted-by: keith@expo.lcs.mit.edu (Keith Packard)
  13. Posting-number: Volume 2, Issue 16
  14. Archive-name: x11.3/patch2
  15.  
  16.  
  17. Here is the second official patch for Xv11r3.  I'll be mailing each
  18. fix directly to you for distribution on comp.sources.x.
  19.  
  20.                         Keith Packard
  21.                         MIT X Consortium
  22.                         (617) 253-1428
  23.                         keith@EXPO.LCS.MIT.EDU
  24.  
  25. The security patches here are IMPORTANT.  Please make your users aware
  26. of the SECURITY section of the xterm manual page, once installed.
  27.  
  28. This patch fixes problems in the following files:
  29.  
  30. server/os/4.2bsd/osinit.c        rgb.dir corruption
  31. server/dix/window.c            core dump on no-op UnmapSubwindows
  32. clients/xterm/xterm.man            provide Secure Keyboard mode and
  33.           ptyx.h            allowSendEvents resource
  34.           button.c
  35.           charproc.c
  36.           Tekproc.c
  37.           menu.c
  38.           misc.c
  39. clients/xdm/Login.c            fix some security problems, make sure
  40.         display.c            error log is on fd 2, fix font nits
  41.         dm.c
  42.         dm.h
  43.         error.c
  44.         greet.c
  45.         pseudoreset.c
  46.         resource.c
  47.         session.c
  48.         verify.c
  49.         xdm.man
  50.  
  51. *** /tmp/,RCSt1a03944    Fri Nov 18 16:35:03 1988
  52. --- server/os/4.2bsd/osinit.c    Mon Nov 14 18:11:44 1988
  53. ***************
  54. *** 21,27 ****
  55.   SOFTWARE.
  56.   
  57.   ******************************************************************/
  58. ! /* $XConsortium: osinit.c,v 1.19 88/10/12 11:12:37 jim Exp $ */
  59.   #include "os.h"
  60.   #include "opaque.h"
  61.   #undef NULL
  62. --- 21,27 ----
  63.   SOFTWARE.
  64.   
  65.   ******************************************************************/
  66. ! /* $XConsortium: osinit.c,v 1.21 88/11/14 18:12:26 rws Exp $ */
  67.   #include "os.h"
  68.   #include "opaque.h"
  69.   #undef NULL
  70. ***************
  71. *** 60,70 ****
  72.       {
  73.           long t; 
  74.           char *ctime();
  75.           fclose(stdin);
  76.           fclose(stdout);
  77.           sprintf (fname, ADMPATH, display);
  78. !         if (!freopen (fname, "a+", stderr))
  79. !         freopen ("/dev/null", "w", stderr);
  80.   #if defined(macII) || defined(hpux)
  81.           {
  82.           static char buf[BUFSIZ];
  83. --- 60,80 ----
  84.       {
  85.           long t; 
  86.           char *ctime();
  87. +         FILE *err;
  88.           fclose(stdin);
  89.           fclose(stdout);
  90.           sprintf (fname, ADMPATH, display);
  91. !         /*
  92. !          * uses stdio to avoid os dependencies here,
  93. !          * a real os would use
  94. !           *  open (fname, O_WRONLY|O_APPEND|O_CREAT, 0666)
  95. !          */
  96. !         if (!(err = fopen (fname, "a+")))
  97. !         err = fopen ("/dev/null", "w");
  98. !         if (err && (fileno(err) != 2)) {
  99. !         dup2 (fileno (err), 2);
  100. !         fclose (err);
  101. !         }
  102.   #if defined(macII) || defined(hpux)
  103.           {
  104.           static char buf[BUFSIZ];
  105.  
  106.  
  107. *** /tmp/,RCSt1a03951    Fri Nov 18 16:36:42 1988
  108. --- server/dix/window.c    Fri Nov 11 09:51:37 1988
  109. ***************
  110. *** 22,28 ****
  111.   
  112.   ******************************************************************/
  113.   
  114. ! /* $XConsortium: window.c,v 1.220 88/10/22 13:27:56 keith Exp $ */
  115.   
  116.   #include "X.h"
  117.   #define NEED_REPLIES
  118. --- 22,28 ----
  119.   
  120.   ******************************************************************/
  121.   
  122. ! /* $XConsortium: window.c,v 1.221 88/11/11 09:52:30 rws Exp $ */
  123.   
  124.   #include "X.h"
  125.   #define NEED_REPLIES
  126. ***************
  127. *** 3273,3278 ****
  128. --- 3273,3280 ----
  129.       Bool anyMarked;
  130.       BoxPtr box;
  131.   
  132. +     if (!pWin->firstChild)
  133. +     return;
  134.       if (wasViewable)
  135.       {
  136.       box = (* pWin->drawable.pScreen->RegionExtents)(pWin->winSize);
  137.  
  138.  
  139. *** /tmp/,RCSt1a03187    Thu Nov 17 17:07:50 1988
  140. --- clients/xterm/xterm.man    Thu Nov 17 16:00:33 1988
  141. ***************
  142. *** 406,411 ****
  143. --- 406,418 ----
  144.   The following resources are specified as part of the ``vt100'' widget (class
  145.   ``VT100''):
  146.   .TP 8
  147. + .B "allowSendEvents (\fPclass\fB AllowSendEvents)"
  148. + Specifies whether or not synthetic key and button events (generated using
  149. + the X protocol SendEvent request) should be interpreted or discarded.
  150. + The default is ``false'' meaning they are discarded.  Note that allowing
  151. + such events creates a very large security hole.
  152. + .sp
  153. + .TP 8
  154.   .B "alwaysHighlight (\fPclass\fB AlwaysHighlight)"
  155.   Specifies whether or not \fIxterm\fP should always display a highlighted 
  156.   text cursor.  By default, a hollow text cursor is displayed whenever the
  157. ***************
  158. *** 730,735 ****
  159. --- 737,746 ----
  160.   pressed in a window.
  161.   The modes section contains items that apply to both the VT102 and Tektronix
  162.   windows.
  163. + The
  164. + .B Secure Keyboard
  165. + mode should be used when typing in passwords or other sensitive data;
  166. + see \fBSECURITY\fP below.
  167.   Notable entries in the command section of the menu are the
  168.   .BR Continue ,
  169.   .BR Suspend ,
  170. ***************
  171. *** 769,774 ****
  172. --- 780,830 ----
  173.   The
  174.   .B PAGE
  175.   entry in the command section clears the Tektronix window.
  176. + .SH SECURITY
  177. + .PP
  178. + X environments differ in their security conciousness.  The servers provided
  179. + by MIT use a host-based mechanism to control access to the server (see
  180. + \fIxhost(1)\fP).  If you enable access for a host, and other users are
  181. + also permitted to run clients on that host, there is the possibility that
  182. + someone will run an application that will attempt to use the basic services
  183. + of the X protocol to snoop on your activities, and potentially capture a
  184. + transcript of everything you type at the keyboard.  This is of particular
  185. + concern when you want to type in a password or other sensitive data.
  186. + The best solution to this problem is for the industry to choose a standard
  187. + authorization mechanism, with the necessary operating system support,
  188. + and to incorporate this into the X protocol (which is already designed to
  189. + handle such a mechanism).  In the mean time, since passwords are most
  190. + commonly typed to something running in an \fIxterm\fP window, a simple
  191. + mechanism exists for protecting keyboard input in \fIxterm\fP.
  192. + .PP
  193. + The \fBxterm\fP menu (see \fBMENUS\fP above) contains a \fBSecure Keyboard\fP
  194. + entry which, when enabled, ensures that all keyboard input is directed
  195. + \fIonly\fP to \fIxterm\fP (using the GrabKeyboard protocol request).
  196. + When an application prompts you for a password
  197. + (or other sensitive data), you can enable \fBSecure Keyboard\fP using the
  198. + menu, type in the data, and then disable \fBSecure Keyboard\fP using
  199. + the menu again.  Only one X client at a time can secure the keyboard,
  200. + so when you attempt to enable \fBSecure Keyboard\fP it may fail.  In
  201. + this case, the bell will sound.  If the \fBSecure Keyboard\fP succeeds,
  202. + the foreground and background colors will be exchanged (as if you
  203. + selected the \fBReverse Video\fP entry in the \fBModes\fP menu);
  204. + they will be exchanged again when you exit secure mode.  If the colors
  205. + do \fInot\fP switch, then
  206. + you should be \fIvery\fP suspicious that you are being spoofed.  If
  207. + the application you are running displays a prompt before asking for
  208. + the password, it is safest to enter secure mode \fIbefore\fP the
  209. + prompt gets displayed, and to make sure that the prompt gets displayed
  210. + correctly (in the new colors), to minimize the probability of
  211. + spoofing.  You can also bring up the menu again and make sure that a check
  212. + mark appears next to the entry.
  213. + .PP
  214. + \fBSecure Keyboard\fP mode will be disabled automatically if your xterm
  215. + window becomes iconified (or otherwise unmapped), or if you start up
  216. + a reparenting window manager (that places a title bar or other decoration
  217. + around the window) while in \fBSecure Keyboard\fP mode.  (This is a
  218. + feature of the X protocol not easily overcome.)  When this happens,
  219. + the foreground and background colors will be switched back and the bell
  220. + will sound in warning.
  221.   .SH "CHARACTER CLASSES"
  222.   Clicking the middle mouse button twice in rapid succession will cause all
  223.   characters of the same class (e.g. letters, white space, punctuation) to be
  224. ***************
  225. *** 835,840 ****
  226. --- 891,899 ----
  227.   is not expected, and will cause unpredictable behavior.
  228.   .PP
  229.   The actions available for key translations are:
  230. + .TP 15
  231. + .B secure()
  232. + Toggles the \fBSecure Keyboard\fP mode; see \fBSECURITY\fP.
  233.   .TP 15
  234.   .B insert()
  235.   Processes the key in the normal way; i.e. inserts the
  236.  
  237.  
  238. *** /tmp/,RCSt1a03192    Thu Nov 17 17:08:04 1988
  239. --- clients/xterm/ptyx.h    Wed Nov 16 18:12:31 1988
  240. ***************
  241. *** 1,5 ****
  242.   /*
  243. !  *    $XConsortium: ptyx.h,v 1.18 88/10/07 14:12:29 swick Exp $
  244.    */
  245.   
  246.   #include <X11/copyright.h>
  247. --- 1,5 ----
  248.   /*
  249. !  *    $XConsortium: ptyx.h,v 1.20 88/11/16 18:13:26 rws Exp $
  250.    */
  251.   
  252.   #include <X11/copyright.h>
  253. ***************
  254. *** 220,225 ****
  255. --- 220,227 ----
  256.       int        select;        /* xterm selected        */
  257.       Boolean        visualbell;    /* visual bell mode        */
  258.       int        logging;    /* logging mode            */
  259. +     Boolean        allowSendEvents;/* SendEvent mode        */
  260. +     Boolean        grabbedKbd;    /* keyboard is grabbed        */
  261.       int        logfd;        /* file descriptor of log    */
  262.       char        *logfile;    /* log file name        */
  263.       char        *logstart;    /* current start of log buffer    */
  264.  
  265.  
  266. *** /tmp/,RCSt1a03197    Thu Nov 17 17:08:16 1988
  267. --- clients/xterm/button.c    Thu Nov 17 15:51:45 1988
  268. ***************
  269. *** 1,5 ****
  270.   /*
  271. !  *    $XConsortium: button.c,v 1.22 88/10/17 20:10:47 swick Exp $
  272.    */
  273.   
  274.   
  275. --- 1,5 ----
  276.   /*
  277. !  *    $XConsortium: button.c,v 1.24 88/11/16 13:48:39 rws Exp $
  278.    */
  279.   
  280.   
  281. ***************
  282. *** 35,41 ****
  283.                   J. Gettys.
  284.   */
  285.   #ifndef lint
  286. ! static char rcs_id[] = "$XConsortium: button.c,v button.c,v 1.22 88/10/17 20:10:47 swick Exp $";
  287.   #endif    /* lint */
  288.   #include <X11/Xos.h>
  289.   #include <X11/Xlib.h>
  290. --- 35,41 ----
  291.                   J. Gettys.
  292.   */
  293.   #ifndef lint
  294. ! static char rcs_id[] = "$XConsortium: button.c,v 1.24 88/11/16 13:48:39 rws Exp $";
  295.   #endif    /* lint */
  296.   #include <X11/Xos.h>
  297.   #include <X11/Xlib.h>
  298. ***************
  299. *** 1246,1253 ****
  300.       TrackMenu(menu, event); /* MenuButtonReleased calls FinishModeMenu */
  301.   }
  302.   
  303. ! FinishModeMenu(item)
  304.   register int item;
  305.   {
  306.       TScreen *screen = &term->screen;
  307.   
  308. --- 1246,1254 ----
  309.       TrackMenu(menu, event); /* MenuButtonReleased calls FinishModeMenu */
  310.   }
  311.   
  312. ! FinishModeMenu(item, time)
  313.   register int item;
  314. + Time time;
  315.   {
  316.       TScreen *screen = &term->screen;
  317.   
  318. ***************
  319. *** 1262,1268 ****
  320.       }
  321.       switch(type) {
  322.        case XTERMMENU:
  323. !         xdomenufunc(item);
  324.           break;
  325.        case VTMENU:
  326.           domenufunc(item);
  327. --- 1263,1269 ----
  328.       }
  329.       switch(type) {
  330.        case XTERMMENU:
  331. !         xdomenufunc(item, time);
  332.           break;
  333.        case VTMENU:
  334.           domenufunc(item);
  335. ***************
  336. *** 1281,1287 ****
  337.           xevents();
  338.   }
  339.   
  340. ! #define    XMENU_VISUALBELL 0
  341.   #define    XMENU_LOG    (XMENU_VISUALBELL+1)
  342.   #define    XMENU_REDRAW    (XMENU_LOG+1)
  343.   #define    XMENU_LINE    (XMENU_REDRAW+1)
  344. --- 1282,1289 ----
  345.           xevents();
  346.   }
  347.   
  348. ! #define XMENU_GRABKBD    0
  349. ! #define    XMENU_VISUALBELL (XMENU_GRABKBD+1)
  350.   #define    XMENU_LOG    (XMENU_VISUALBELL+1)
  351.   #define    XMENU_REDRAW    (XMENU_LOG+1)
  352.   #define    XMENU_LINE    (XMENU_REDRAW+1)
  353. ***************
  354. *** 1295,1300 ****
  355. --- 1297,1303 ----
  356.   #define XMENU_EXIT    (XMENU_LINE2+1)
  357.   
  358.   static char *xtext[] = {
  359. +     "Secure Keyboard",
  360.       "Visual Bell",
  361.       "Logging",
  362.       "Redraw",
  363. ***************
  364. *** 1312,1317 ****
  365. --- 1315,1321 ----
  366.   
  367.   static int xbell;
  368.   static int xlog;
  369. + static int xkgrab;
  370.   
  371.   Menu *xsetupmenu(menu)
  372.   register Menu **menu;
  373. ***************
  374. *** 1325,1330 ****
  375. --- 1329,1336 ----
  376.               return(NULL);
  377.           for(cp = xtext ; *cp ; cp++)
  378.               AddMenuItem(*menu, *cp);
  379. +         if(xkgrab = screen->grabbedKbd)
  380. +             CheckItem(*menu, XMENU_GRABKBD);
  381.           if(xbell = screen->visualbell)
  382.               CheckItem(*menu, XMENU_VISUALBELL);
  383.           if(xlog = screen->logging)
  384. ***************
  385. *** 1346,1351 ****
  386. --- 1352,1360 ----
  387.       /* if login window, check for completed login */
  388.       if (!(L_flag && !checklogin()) && !(screen->inhibit & I_LOG))
  389.           EnableItem(*menu, XMENU_LOG);
  390. +     if (xkgrab != screen->grabbedKbd)
  391. +         SetItemCheck(*menu, XMENU_GRABKBD, (xkgrab =
  392. +          screen->grabbedKbd));
  393.       if (xbell != screen->visualbell)
  394.           SetItemCheck(*menu, XMENU_VISUALBELL, (xbell =
  395.            screen->visualbell));
  396. ***************
  397. *** 1354,1365 ****
  398.       return(*menu);
  399.   }
  400.   
  401. ! xdomenufunc(item)
  402.   int item;
  403.   {
  404.       register TScreen *screen = &term->screen;
  405.   
  406.       switch (item) {
  407.       case XMENU_VISUALBELL:
  408.           screen->visualbell = !screen->visualbell;
  409.           break;
  410. --- 1363,1393 ----
  411.       return(*menu);
  412.   }
  413.   
  414. ! xdomenufunc(item, time)
  415.   int item;
  416. + Time time;
  417.   {
  418.       register TScreen *screen = &term->screen;
  419.   
  420.       switch (item) {
  421. +     case XMENU_GRABKBD:
  422. +         if (screen->grabbedKbd) {
  423. +             XUngrabKeyboard(screen->display, time);
  424. +             ReverseVideo(term);
  425. +             screen->grabbedKbd = FALSE;
  426. +         } else {
  427. +             if (XGrabKeyboard(screen->display,
  428. +                       term->core.parent->core.window,
  429. +                       True, GrabModeAsync, GrabModeAsync, time)
  430. +               != GrabSuccess) {
  431. +                 XBell(screen->display, 100);
  432. +             } else {
  433. +             ReverseVideo(term);
  434. +             screen->grabbedKbd = TRUE;
  435. +             }
  436. +         }
  437. +         break;
  438.       case XMENU_VISUALBELL:
  439.           screen->visualbell = !screen->visualbell;
  440.           break;
  441. ***************
  442. *** 1489,1492 ****
  443. --- 1517,1538 ----
  444.   XButtonEvent *event;
  445.   {
  446.       Bell();
  447. + }
  448. + /* ARGSUSED */
  449. + void HandleSecure(w, event, params, param_count)
  450. +     Widget w;
  451. +     XEvent *event;        /* unused */
  452. +     String *params;        /* [0] = volume */
  453. +     Cardinal *param_count;    /* 0 or 1 */
  454. + {
  455. +     Time time = CurrentTime;
  456. +     if ((event->xany.type == KeyPress) ||
  457. +     (event->xany.type == KeyRelease))
  458. +     time = event->xkey.time;
  459. +     else if ((event->xany.type == ButtonPress) ||
  460. +          (event->xany.type == ButtonRelease))
  461. +       time = event->xbutton.time;
  462. +     xdomenufunc(XMENU_GRABKBD, time);
  463.   }
  464.  
  465.  
  466. *** /tmp/,RCSt1a03202    Thu Nov 17 17:09:11 1988
  467. --- clients/xterm/charproc.c    Wed Nov 16 18:14:30 1988
  468. ***************
  469. *** 1,5 ****
  470.   /*
  471. !  * $XConsortium: charproc.c,v 1.60 88/10/10 13:02:12 swick Exp $
  472.    */
  473.   
  474.   
  475. --- 1,5 ----
  476.   /*
  477. !  * $XConsortium: charproc.c,v 1.62 88/11/16 18:15:34 rws Exp $
  478.    */
  479.   
  480.   
  481. ***************
  482. *** 100,105 ****
  483. --- 100,106 ----
  484.   #define    XtNtekStartup        "tekStartup"
  485.   #define XtNtiteInhibit        "titeInhibit"
  486.   #define    XtNvisualBell        "visualBell"
  487. + #define XtNallowSendEvents    "allowSendEvents"
  488.   
  489.   #define XtCAlwaysHighlight    "AlwaysHighlight"
  490.   #define    XtCC132            "C132"
  491. ***************
  492. *** 128,138 ****
  493.   #define    XtCTekStartup        "TekStartup"
  494.   #define XtCTiteInhibit        "TiteInhibit"
  495.   #define    XtCVisualBell        "VisualBell"
  496.   
  497.   #define    doinput()        (bcnt-- > 0 ? *bptr++ : in_put())
  498.   
  499.   #ifndef lint
  500. ! static char rcs_id[] = "$XConsortium: charproc.c,v 1.60 88/10/10 13:02:12 swick Exp $";
  501.   #endif    /* lint */
  502.   
  503.   static long arg;
  504. --- 129,140 ----
  505.   #define    XtCTekStartup        "TekStartup"
  506.   #define XtCTiteInhibit        "TiteInhibit"
  507.   #define    XtCVisualBell        "VisualBell"
  508. + #define XtCAllowSendEvents    "AllowSendEvents"
  509.   
  510.   #define    doinput()        (bcnt-- > 0 ? *bptr++ : in_put())
  511.   
  512.   #ifndef lint
  513. ! static char rcs_id[] = "$XConsortium: charproc.c,v 1.62 88/11/16 18:15:34 rws Exp $";
  514.   #endif    /* lint */
  515.   
  516.   static long arg;
  517. ***************
  518. *** 170,175 ****
  519. --- 172,178 ----
  520.   extern void HandleStartExtend();
  521.          void HandleBell();
  522.          void HandleIgnore();
  523. + extern void HandleSecure();
  524.   
  525.   /*
  526.    * NOTE: VTInitialize zeros out the entire ".screen" component of the 
  527. ***************
  528. *** 208,213 ****
  529. --- 211,217 ----
  530.       { "insert-selection", HandleInsertSelection },
  531.       { "keymap",       HandleKeymapChange },
  532.       { "mode-menu",      HandleModeMenu },
  533. +     { "secure",          HandleSecure },
  534.       { "select-start",      HandleSelectStart },
  535.       { "select-extend",      HandleSelectExtend },
  536.       { "select-end",      HandleSelectEnd },
  537. ***************
  538. *** 323,328 ****
  539. --- 327,335 ----
  540.       XtRBoolean, (caddr_t) &defaultFALSE},
  541.   {XtNvisualBell, XtCVisualBell, XtRBoolean, sizeof(Boolean),
  542.       XtOffset(XtermWidget, screen.visualbell),
  543. +     XtRBoolean, (caddr_t) &defaultFALSE},
  544. + {XtNallowSendEvents, XtCAllowSendEvents, XtRBoolean, sizeof(Boolean),
  545. +     XtOffset(XtermWidget, screen.allowSendEvents),
  546.       XtRBoolean, (caddr_t) &defaultFALSE}
  547.   };
  548.   
  549.  
  550. *** /tmp/,RCSt1a03209    Thu Nov 17 17:09:20 1988
  551. --- clients/xterm/Tekproc.c    Wed Nov 16 13:43:58 1988
  552. ***************
  553. *** 1,5 ****
  554.   /*
  555. !  * $XConsortium: Tekproc.c,v 1.43 88/10/07 13:28:23 jim Exp $
  556.    *
  557.    * Warning, there be crufty dragons here.
  558.    */
  559. --- 1,5 ----
  560.   /*
  561. !  * $XConsortium: Tekproc.c,v 1.44 88/11/16 13:45:06 rws Exp $
  562.    *
  563.    * Warning, there be crufty dragons here.
  564.    */
  565. ***************
  566. *** 121,127 ****
  567.   #define    unput(c)    *Tpushback++ = c
  568.   
  569.   #ifndef lint
  570. ! static char rcs_id[] = "$XConsortium: Tekproc.c,v 1.43 88/10/07 13:28:23 jim Exp $";
  571.   #endif    /* lint */
  572.   
  573.   static XPoint *T_box[TEKNUMFONTS] = {
  574. --- 121,127 ----
  575.   #define    unput(c)    *Tpushback++ = c
  576.   
  577.   #ifndef lint
  578. ! static char rcs_id[] = "$XConsortium: Tekproc.c,v 1.44 88/11/16 13:45:06 rws Exp $";
  579.   #endif    /* lint */
  580.   
  581.   static XPoint *T_box[TEKNUMFONTS] = {
  582. ***************
  583. *** 168,173 ****
  584. --- 168,174 ----
  585.   extern void HandleEnterWindow();
  586.   extern void HandleLeaveWindow();
  587.   extern void HandleFocusChange();
  588. + extern void HandleSecure();
  589.   extern void TekButtonPressed();
  590.   
  591.   static char defaultTranslations[] = 
  592. ***************
  593. *** 176,181 ****
  594. --- 177,183 ----
  595.   static XtActionsRec actionsList[] = { 
  596.       { "string",    HandleStringEvent },
  597.       { "insert",    HandleKeyPressed },
  598. +     { "secure", HandleSecure }
  599.   };
  600.   
  601.   static Dimension defOne = 1;
  602.  
  603.  
  604. *** /tmp/,RCSt1a03215    Thu Nov 17 17:09:25 1988
  605. --- clients/xterm/menu.c    Wed Nov 16 13:46:22 1988
  606. ***************
  607. *** 2,8 ****
  608.   static char sccsid[]="@(#)menu.c    1.7 Stellar 87/10/16";
  609.   #endif
  610.   /*
  611. !  *    $XConsortium: menu.c,v 1.10 88/10/05 11:16:29 jim Exp $
  612.    */
  613.   
  614.   #include <X11/copyright.h>
  615. --- 2,8 ----
  616.   static char sccsid[]="@(#)menu.c    1.7 Stellar 87/10/16";
  617.   #endif
  618.   /*
  619. !  *    $XConsortium: menu.c,v 1.11 88/11/16 13:47:32 rws Exp $
  620.    */
  621.   
  622.   #include <X11/copyright.h>
  623. ***************
  624. *** 45,51 ****
  625.   #include "data.h"
  626.   
  627.   #ifndef lint
  628. ! static char rcs_id[] = "$XConsortium: menu.c,v 1.10 88/10/05 11:16:29 jim Exp $";
  629.   #endif    lint
  630.   
  631.   #define DEFMENUBORDER    2
  632. --- 45,51 ----
  633.   #include "data.h"
  634.   
  635.   #ifndef lint
  636. ! static char rcs_id[] = "$XConsortium: menu.c,v 1.11 88/11/16 13:47:32 rws Exp $";
  637.   #endif    lint
  638.   
  639.   #define DEFMENUBORDER    2
  640. ***************
  641. *** 489,497 ****
  642.       Unmap_Menu(menu);
  643.       drawn = 0;
  644.       if(hilited_item)
  645. !         FinishModeMenu(menu->menuInitialItem = hilited_n);
  646.       else
  647. !         FinishModeMenu(-1);
  648.   }
  649.   
  650.   /*
  651. --- 489,498 ----
  652.       Unmap_Menu(menu);
  653.       drawn = 0;
  654.       if(hilited_item)
  655. !         FinishModeMenu(menu->menuInitialItem = hilited_n,
  656. !                    event->time);
  657.       else
  658. !         FinishModeMenu(-1, event->time);
  659.   }
  660.   
  661.   /*
  662.  
  663.  
  664. *** /tmp/,RCSt1a03220    Thu Nov 17 17:09:30 1988
  665. --- clients/xterm/misc.c    Thu Nov 17 16:06:48 1988
  666. ***************
  667. *** 1,5 ****
  668.   /*
  669. !  *    $XConsortium: misc.c,v 1.24 88/10/07 13:25:28 jim Exp $
  670.    */
  671.   
  672.   
  673. --- 1,5 ----
  674.   /*
  675. !  *    $XConsortium: misc.c,v 1.28 88/11/17 16:07:46 rws Exp $
  676.    */
  677.   
  678.   
  679. ***************
  680. *** 53,59 ****
  681.   extern void abort();
  682.   
  683.   #ifndef lint
  684. ! static char rcs_id[] = "$XConsortium: misc.c,v 1.24 88/10/07 13:25:28 jim Exp $";
  685.   #endif    /* lint */
  686.   
  687.   xevents()
  688. --- 53,59 ----
  689.   extern void abort();
  690.   
  691.   #ifndef lint
  692. ! static char rcs_id[] = "$XConsortium: misc.c,v 1.28 88/11/17 16:07:46 rws Exp $";
  693.   #endif    /* lint */
  694.   
  695.   xevents()
  696. ***************
  697. *** 68,74 ****
  698.           if (waitingForTrackInfo)
  699.               return;
  700.           XNextEvent (screen->display, &event);
  701. !         XtDispatchEvent(&event);
  702.       } while (QLength(screen->display) > 0);
  703.   }
  704.   
  705. --- 68,80 ----
  706.           if (waitingForTrackInfo)
  707.               return;
  708.           XNextEvent (screen->display, &event);
  709. !         if (!event.xany.send_event ||
  710. !             screen->allowSendEvents ||
  711. !             ((event.xany.type != KeyPress) &&
  712. !              (event.xany.type != KeyRelease) &&
  713. !              (event.xany.type != ButtonPress) &&
  714. !              (event.xany.type != ButtonRelease)))
  715. !             XtDispatchEvent(&event);
  716.       } while (QLength(screen->display) > 0);
  717.   }
  718.   
  719. ***************
  720. *** 184,192 ****
  721.           register TScreen *screen = &term->screen;
  722.   
  723.           if(event->type == FocusIn)
  724. !                 selectwindow(screen, FOCUS);
  725. !         else
  726. !                 unselectwindow(screen, FOCUS);
  727.   }
  728.   
  729.   
  730. --- 190,208 ----
  731.           register TScreen *screen = &term->screen;
  732.   
  733.           if(event->type == FocusIn)
  734. !                 selectwindow(screen,
  735. !                  (event->detail == NotifyPointer) ? INWINDOW :
  736. !                                 FOCUS);
  737. !         else {
  738. !                 unselectwindow(screen,
  739. !                    (event->detail == NotifyPointer) ? INWINDOW :
  740. !                                   FOCUS);
  741. !         if (screen->grabbedKbd && (event->mode == NotifyUngrab)) {
  742. !             screen->grabbedKbd = FALSE;
  743. !             ReverseVideo(term);
  744. !             XBell(screen->display, 100);
  745. !         }
  746. !     }
  747.   }
  748.   
  749.   
  750. *** /tmp/,RCSt1a03978    Fri Nov 18 16:45:30 1988
  751. --- clients/xdm/Login.c    Thu Nov 17 17:04:42 1988
  752. ***************
  753. *** 1,7 ****
  754.   /*
  755.    * xdm - display manager daemon
  756.    *
  757. !  * $XConsortium: Login.c,v 1.9 88/10/22 10:41:01 rws Exp $
  758.    *
  759.    * Copyright 1988 Massachusetts Institute of Technology
  760.    *
  761. --- 1,7 ----
  762.   /*
  763.    * xdm - display manager daemon
  764.    *
  765. !  * $XConsortium: Login.c,v 1.11 88/11/17 17:04:15 keith Exp $
  766.    *
  767.    * Copyright 1988 Massachusetts Institute of Technology
  768.    *
  769. ***************
  770. *** 50,62 ****
  771.       {XtNfailColor, XtCForeground, XtRPixel, sizeof (Pixel),
  772.       offset(failpixel), XtRString,    "Black"},
  773.       {XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  774. !         offset (font), XtRString,    "*-new century schoolbook-medium-r-normal-*-18-*"},
  775.       {XtNpromptFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  776. !         offset (promptFont), XtRString, "*-new century schoolbook-bold-r-normal-*-18-*"},
  777.       {XtNgreetFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  778. !         offset (greetFont), XtRString,    "*-new century schoolbook-bold-i-normal-*-24-*"},
  779.       {XtNfailFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  780. !     offset (failFont), XtRString,    "*-new century schoolbook-bold-r-normal-*-18-*"},
  781.       {XtNgreeting, XtCGreeting, XtRString, sizeof (char *),
  782.           offset(greeting), XtRString, "Welcome to the X Window System"},
  783.       {XtNnamePrompt, XtCNamePrompt, XtRString, sizeof (char *),
  784. --- 50,62 ----
  785.       {XtNfailColor, XtCForeground, XtRPixel, sizeof (Pixel),
  786.       offset(failpixel), XtRString,    "Black"},
  787.       {XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  788. !         offset (font), XtRString,    "*-new century schoolbook-medium-r-normal-*-180-*"},
  789.       {XtNpromptFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  790. !         offset (promptFont), XtRString, "*-new century schoolbook-bold-r-normal-*-180-*"},
  791.       {XtNgreetFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  792. !         offset (greetFont), XtRString,    "*-new century schoolbook-bold-i-normal-*-240-*"},
  793.       {XtNfailFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  794. !     offset (failFont), XtRString,    "*-new century schoolbook-bold-r-normal-*-180-*"},
  795.       {XtNgreeting, XtCGreeting, XtRString, sizeof (char *),
  796.           offset(greeting), XtRString, "Welcome to the X Window System"},
  797.       {XtNnamePrompt, XtCNamePrompt, XtRString, sizeof (char *),
  798. ***************
  799. *** 271,277 ****
  800.       DrawFail (w);
  801.       DrawName (w, 0);
  802.       XorCursor (w);
  803. !     XSetInputFocus (XtDisplay (w), XtWindow (w), RevertToPointerRoot, CurrentTime);
  804.   }
  805.   
  806.   static void
  807. --- 271,290 ----
  808.       DrawFail (w);
  809.       DrawName (w, 0);
  810.       XorCursor (w);
  811. !     /*
  812. !      * The GrabKeyboard here is needed only because of
  813. !      * a bug in the R3 server -- the keyboard is grabbed on
  814. !      * the root window, and the server won't dispatch events
  815. !      * to the focus window unless the focus window is a ancestor
  816. !      * of the grab window.  Bug in server already found and fixed,
  817. !      * compatibility until at least R4.
  818. !      */
  819. !     if (XGrabKeyboard (XtDisplay (w), XtWindow (w), False, GrabModeAsync,
  820. !                GrabModeAsync, CurrentTime) != GrabSuccess)
  821. !     {
  822. !     XSetInputFocus (XtDisplay (w), XtWindow (w),
  823. !             RevertToPointerRoot, CurrentTime);
  824. !     }
  825.   }
  826.   
  827.   static void
  828.  
  829.  
  830. *** /tmp/,RCSt1a03985    Fri Nov 18 16:48:02 1988
  831. --- clients/xdm/display.c    Thu Nov 17 17:04:47 1988
  832. ***************
  833. *** 1,7 ****
  834.   /*
  835.    * xdm - display manager daemon
  836.    *
  837. !  * $XConsortium: display.c,v 1.9 88/10/22 21:49:08 keith Exp $
  838.    *
  839.    * Copyright 1988 Massachusetts Institute of Technology
  840.    *
  841. --- 1,7 ----
  842.   /*
  843.    * xdm - display manager daemon
  844.    *
  845. !  * $XConsortium: display.c,v 1.10 88/11/17 17:04:43 keith Exp $
  846.    *
  847.    * Copyright 1988 Massachusetts Institute of Technology
  848.    *
  849. ***************
  850. *** 78,87 ****
  851.       Debug ("manage display %s\n", d->name);
  852.       if (setjmp (terminated)) {
  853.           Debug ("processing SIGTERM\n");
  854. -         TerminateServer (d, serverPid);
  855.           if (sessionPid < 2)
  856.               abort ();
  857.           (void) killpg (sessionPid, SIGTERM);
  858.           exit (OBEYSESS_DISPLAY);
  859.       }
  860.       (void) signal (SIGTERM, CatchTerm);
  861. --- 78,87 ----
  862.       Debug ("manage display %s\n", d->name);
  863.       if (setjmp (terminated)) {
  864.           Debug ("processing SIGTERM\n");
  865.           if (sessionPid < 2)
  866.               abort ();
  867.           (void) killpg (sessionPid, SIGTERM);
  868. +         TerminateServer (d, serverPid);
  869.           exit (OBEYSESS_DISPLAY);
  870.       }
  871.       (void) signal (SIGTERM, CatchTerm);
  872. ***************
  873. *** 351,357 ****
  874. --- 351,359 ----
  875.   #ifdef UDP_SOCKET
  876.           Debug ("sending TERMINATE message through network\n");
  877.           if (!serverMessage (d, TERMINATE) && dpy)
  878. +             pseudoReset (dpy);
  879.   #else
  880. +         if (dpy)
  881.               pseudoReset (dpy);
  882.   #endif
  883.           if (dpy) {
  884.  
  885.  
  886. *** /tmp/,RCSt1a03992    Fri Nov 18 16:48:52 1988
  887. --- clients/xdm/dm.c    Thu Nov 17 17:04:52 1988
  888. ***************
  889. *** 1,7 ****
  890.   /*
  891.    * xdm - display manager daemon
  892.    *
  893. !  * $XConsortium: dm.c,v 1.9 88/10/22 21:48:44 keith Exp $
  894.    *
  895.    * Copyright 1988 Massachusetts Institute of Technology
  896.    *
  897. --- 1,7 ----
  898.   /*
  899.    * xdm - display manager daemon
  900.    *
  901. !  * $XConsortium: dm.c,v 1.10 88/11/17 17:04:50 keith Exp $
  902.    *
  903.    * Copyright 1988 Massachusetts Institute of Technology
  904.    *
  905. ***************
  906. *** 41,46 ****
  907. --- 41,47 ----
  908.       if (debugLevel == 0 && daemonMode)
  909.           BecomeDaemon ();
  910.       InitErrorLog ();
  911. +     StorePid ();
  912.       signal (SIGTERM, TerminateAll);
  913.       signal (SIGINT, TerminateAll);
  914.       /*
  915. ***************
  916. *** 276,279 ****
  917. --- 277,296 ----
  918.               close (fd);
  919.       FD_ZERO (&CloseMask);
  920.       max = 0;
  921. + }
  922. + StorePid ()
  923. + {
  924. +     FILE    *f;
  925. +     if (pidFile[0] != '\0') {
  926. +         f = fopen (pidFile, "w");
  927. +         if (!f) {
  928. +             LogError ("process-id file %s cannot be opened\n",
  929. +                   pidFile);
  930. +         } else {
  931. +             fprintf (f, "%d\n", getpid ());
  932. +             fclose (f);
  933. +         }
  934. +     }
  935.   }
  936.  
  937.  
  938. *** /tmp/,RCSt1a03999    Fri Nov 18 16:49:28 1988
  939. --- clients/xdm/dm.h    Thu Nov 17 17:04:55 1988
  940. ***************
  941. *** 1,7 ****
  942.   /*
  943.    * xdm - display manager daemon
  944.    *
  945. !  * $XConsortium: dm.h,v 1.8 88/10/22 21:49:03 keith Exp $
  946.    *
  947.    * Copyright 1988 Massachusetts Institute of Technology
  948.    *
  949. --- 1,7 ----
  950.   /*
  951.    * xdm - display manager daemon
  952.    *
  953. !  * $XConsortium: dm.h,v 1.9 88/11/17 17:04:53 keith Exp $
  954.    *
  955.    * Copyright 1988 Massachusetts Institute of Technology
  956.    *
  957. ***************
  958. *** 96,101 ****
  959. --- 96,102 ----
  960.       FileState    state;        /* state during HUP processing */
  961.       char        *resources;    /* resource file */
  962.       char        *xrdb;        /* xrdb program */
  963. +     char        *cpp;        /* cpp program */
  964.       char        *startup;    /* Xstartup program */
  965.       char        *reset;        /* Xreset program */
  966.       char        *session;    /* Xsession program */
  967. ***************
  968. *** 107,112 ****
  969. --- 108,114 ----
  970.       int        openRepeat;    /* open attempts to make */
  971.       int        openTimeout;    /* abort open attempt timeout */
  972.       int        terminateServer;/* restart for each session */
  973. +     int        grabTimeout;    /* time to wait for grab */
  974.       DisplayType    displayType;    /* method to handle with */
  975.   #ifdef UDP_SOCKET
  976.       struct sockaddr_in    addr;    /* address used in connection */
  977. ***************
  978. *** 150,155 ****
  979. --- 152,158 ----
  980.   extern int    debugLevel;
  981.   extern char    *errorLogFile;
  982.   extern int    daemonMode;
  983. + extern char    *pidFile;
  984.   
  985.   extern struct display    *FindDisplayByName (),
  986.               *FindDisplayByPid (),
  987.  
  988.  
  989. *** /tmp/,RCSt1a03960    Fri Nov 18 16:38:14 1988
  990. --- clients/xdm/error.c    Mon Nov 14 12:29:33 1988
  991. ***************
  992. *** 1,7 ****
  993.   /*
  994.    * xdm - display manager daemon
  995.    *
  996. !  * $XConsortium: error.c,v 1.5 88/10/15 19:09:58 keith Exp $
  997.    *
  998.    * Copyright 1988 Massachusetts Institute of Technology
  999.    *
  1000. --- 1,7 ----
  1001.   /*
  1002.    * xdm - display manager daemon
  1003.    *
  1004. !  * $XConsortium: error.c,v 1.6 88/11/14 12:29:19 keith Exp $
  1005.    *
  1006.    * Copyright 1988 Massachusetts Institute of Technology
  1007.    *
  1008. ***************
  1009. *** 34,41 ****
  1010.       if (errorLogFile[0]) {
  1011.           i = creat (errorLogFile, 0666);
  1012.           if (i != -1) {
  1013. !             close (i);
  1014. !             freopen (errorLogFile, "a+", stderr);
  1015.           } else
  1016.               LogError ("Cannot open errorLogFile %s\n", errorLogFile);
  1017.       }
  1018. --- 34,43 ----
  1019.       if (errorLogFile[0]) {
  1020.           i = creat (errorLogFile, 0666);
  1021.           if (i != -1) {
  1022. !             if (i != 2) {
  1023. !                 dup2 (i, 2);
  1024. !                 close (i);
  1025. !             }
  1026.           } else
  1027.               LogError ("Cannot open errorLogFile %s\n", errorLogFile);
  1028.       }
  1029.  
  1030.  
  1031. *** /tmp/,RCSt1a04006    Fri Nov 18 16:50:50 1988
  1032. --- clients/xdm/greet.c    Thu Nov 17 17:04:57 1988
  1033. ***************
  1034. *** 1,7 ****
  1035.   /*
  1036.    * xdm - display manager daemon
  1037.    *
  1038. !  * $XConsortium: greet.c,v 1.6 88/10/20 17:37:02 keith Exp $
  1039.    *
  1040.    * Copyright 1988 Massachusetts Institute of Technology
  1041.    *
  1042. --- 1,7 ----
  1043.   /*
  1044.    * xdm - display manager daemon
  1045.    *
  1046. !  * $XConsortium: greet.c,v 1.7 88/11/17 17:04:56 keith Exp $
  1047.    *
  1048.    * Copyright 1988 Massachusetts Institute of Technology
  1049.    *
  1050. ***************
  1051. *** 41,46 ****
  1052. --- 41,47 ----
  1053.   static Widget        login;
  1054.   static Widget        logoToplevel;
  1055.   static Widget        logo;
  1056. + static XtAppContext    context;
  1057.   
  1058.   GreetDone (w, data, status)
  1059.       Widget    w;
  1060. ***************
  1061. *** 66,71 ****
  1062. --- 67,73 ----
  1063.       }
  1064.   }
  1065.   
  1066. + Display *
  1067.   InitGreet (d)
  1068.   struct display    *d;
  1069.   {
  1070. ***************
  1071. *** 72,91 ****
  1072.       Arg        arglist[10];
  1073.       int        i;
  1074.       int        argc;
  1075.       static char    *argv[] = { "xlogin", "-display", 0, 0 };
  1076.   
  1077.       Debug ("greet %s\n", d->name);
  1078.       argv[2] = d->name;
  1079.       argc = 3;
  1080. !     toplevel = XtInitialize ("main", "Xlogin", 0, 0, &argc, argv);
  1081. !     Debug ("top level shell created\n");
  1082.   
  1083.       i = 0;
  1084. !     XtSetArg (arglist[i], XtNnotifyDone, GreetDone); i++;
  1085.   
  1086.       login = XtCreateManagedWidget ("login", loginWidgetClass, toplevel,
  1087.                       arglist, i);
  1088.       XtRealizeWidget (toplevel);
  1089.   #ifdef DRAWLOGO
  1090.       i = 0;
  1091.       XtSetArg (arglist[i], XtNgeometry, "100x100-0-0"); i++;
  1092. --- 74,108 ----
  1093.       Arg        arglist[10];
  1094.       int        i;
  1095.       int        argc;
  1096. +     Screen        *scrn;
  1097.       static char    *argv[] = { "xlogin", "-display", 0, 0 };
  1098. +     Display        *dpy;
  1099.   
  1100.       Debug ("greet %s\n", d->name);
  1101.       argv[2] = d->name;
  1102.       argc = 3;
  1103. !     XtToolkitInitialize ();
  1104. !     context = XtCreateApplicationContext();
  1105. !     dpy = XtOpenDisplay (context, d->name, "xlogin", "Xlogin", 0,0,
  1106. !                 &argc, argv);
  1107.   
  1108. +     SecureDisplay (d, dpy);
  1109.       i = 0;
  1110. !     scrn = DefaultScreenOfDisplay(dpy);
  1111. !         XtSetArg(arglist[i], XtNscreen, scrn);    i++;
  1112. !     XtSetArg(arglist[i], XtNargc, argc);    i++;
  1113. !     XtSetArg(arglist[i], XtNargv, argv);    i++;
  1114.   
  1115. +     toplevel = XtAppCreateShell ((String) NULL, "Xlogin",
  1116. +             applicationShellWidgetClass, dpy, arglist, i);
  1117. +     i = 0;
  1118. +     XtSetArg (arglist[i], XtNnotifyDone, GreetDone); i++;
  1119.       login = XtCreateManagedWidget ("login", loginWidgetClass, toplevel,
  1120.                       arglist, i);
  1121.       XtRealizeWidget (toplevel);
  1122.   #ifdef DRAWLOGO
  1123.       i = 0;
  1124.       XtSetArg (arglist[i], XtNgeometry, "100x100-0-0"); i++;
  1125. ***************
  1126. *** 96,106 ****
  1127. --- 113,125 ----
  1128.                       arglist, i);
  1129.       XtRealizeWidget (logoToplevel);
  1130.   #endif
  1131. +     return dpy;
  1132.   }
  1133.   
  1134.   CloseGreet (d)
  1135.   struct display    *d;
  1136.   {
  1137. +     UnsecureDisplay (d, XtDisplay (toplevel));
  1138.       XCloseDisplay (XtDisplay (toplevel));
  1139.   }
  1140.   
  1141. ***************
  1142. *** 109,127 ****
  1143.   struct greet_info    *greet;
  1144.   {
  1145.       XEvent        event;
  1146. !     Arg        args[1];
  1147.   
  1148.       Debug ("dispatching\n");
  1149.       done = 0;
  1150.       while (!done) {
  1151. !         XtAppNextEvent (_XtDefaultAppContext(), &event);
  1152.           XtDispatchEvent (&event);
  1153.       }
  1154.       XFlush (XtDisplay (toplevel));
  1155.       greet->name = name;
  1156.       greet->password = password;
  1157. !     XtSetArg (args[0], XtNsessionArgument, (char *) &(greet->string));
  1158. !     XtGetValues (login, args, 1);
  1159.       Debug ("sessionArgument: %s\n", greet->string ? greet->string : "<NULL>");
  1160.   }
  1161.   
  1162. --- 128,146 ----
  1163.   struct greet_info    *greet;
  1164.   {
  1165.       XEvent        event;
  1166. !     Arg        arglist[1];
  1167.   
  1168.       Debug ("dispatching\n");
  1169.       done = 0;
  1170.       while (!done) {
  1171. !         XtAppNextEvent (context, &event);
  1172.           XtDispatchEvent (&event);
  1173.       }
  1174.       XFlush (XtDisplay (toplevel));
  1175.       greet->name = name;
  1176.       greet->password = password;
  1177. !     XtSetArg (arglist[0], XtNsessionArgument, (char *) &(greet->string));
  1178. !     XtGetValues (login, arglist, 1);
  1179.       Debug ("sessionArgument: %s\n", greet->string ? greet->string : "<NULL>");
  1180.   }
  1181.   
  1182.  
  1183. *** /tmp/,RCSt1a04013    Fri Nov 18 16:51:27 1988
  1184. --- clients/xdm/pseudoreset.c    Thu Nov 17 17:05:00 1988
  1185. ***************
  1186. *** 1,7 ****
  1187.   /*
  1188.    * xdm - display manager daemon
  1189.    *
  1190. !  * $XConsortium: pseudoreset.c,v 1.1 88/10/15 19:06:00 keith Exp $
  1191.    *
  1192.    * Copyright 1988 Massachusetts Institute of Technology
  1193.    *
  1194. --- 1,7 ----
  1195.   /*
  1196.    * xdm - display manager daemon
  1197.    *
  1198. !  * $XConsortium: pseudoreset.c,v 1.2 88/11/17 17:04:58 keith Exp $
  1199.    *
  1200.    * Copyright 1988 Massachusetts Institute of Technology
  1201.    *
  1202. ***************
  1203. *** 31,36 ****
  1204. --- 31,37 ----
  1205.   Display    *dpy;
  1206.   XErrorEvent    *event;
  1207.   {
  1208. +     Debug ("ignoring error\n");
  1209.   }
  1210.   
  1211.   /*
  1212. ***************
  1213. *** 50,57 ****
  1214.       while (XQueryTree (dpy, window, &root, &parent, &children, &nchildren)
  1215.              && nchildren > 0)
  1216.       {
  1217. !         for (child = 0; child < nchildren; child++)
  1218.               XKillClient (dpy, children[child]);
  1219.           XFree (children);
  1220.       }
  1221.   }
  1222. --- 51,60 ----
  1223.       while (XQueryTree (dpy, window, &root, &parent, &children, &nchildren)
  1224.              && nchildren > 0)
  1225.       {
  1226. !         for (child = 0; child < nchildren; child++) {
  1227. !             Debug ("XKillClient 0x%x\n", children[child]);
  1228.               XKillClient (dpy, children[child]);
  1229. +         }
  1230.           XFree (children);
  1231.       }
  1232.   }
  1233. ***************
  1234. *** 68,76 ****
  1235. --- 71,82 ----
  1236.   
  1237.       XSetErrorHandler (ignoreErrors);
  1238.       for (screen = 0; screen < ScreenCount (dpy); screen++) {
  1239. +         Debug ("pseudoReset screen %d\n", screen);
  1240.           root = RootWindow (dpy, screen);
  1241.           killWindows (dpy, root);
  1242.       }
  1243. +     Debug ("before XSync\n");
  1244.       XSync (dpy, False);
  1245.       XSetErrorHandler ((int (*)) 0);
  1246. +     Debug ("pseudoReset done\n");
  1247.   }
  1248.  
  1249.  
  1250. *** /tmp/,RCSt1a04020    Fri Nov 18 16:52:06 1988
  1251. --- clients/xdm/resource.c    Thu Nov 17 17:05:04 1988
  1252. ***************
  1253. *** 1,7 ****
  1254.   /*
  1255.    * xdm - display manager daemon
  1256.    *
  1257. !  * $XConsortium: resource.c,v 1.9 88/10/25 11:48:47 keith Exp $
  1258.    *
  1259.    * Copyright 1988 Massachusetts Institute of Technology
  1260.    *
  1261. --- 1,7 ----
  1262.   /*
  1263.    * xdm - display manager daemon
  1264.    *
  1265. !  * $XConsortium: resource.c,v 1.10 88/11/17 17:05:01 keith Exp $
  1266.    *
  1267.    * Copyright 1988 Massachusetts Institute of Technology
  1268.    *
  1269. ***************
  1270. *** 33,38 ****
  1271. --- 33,39 ----
  1272.   int    debugLevel;
  1273.   char    *errorLogFile;
  1274.   int    daemonMode;
  1275. + char    *pidFile;
  1276.   
  1277.   # define DM_STRING    0
  1278.   # define DM_INT        1
  1279. ***************
  1280. *** 67,74 ****
  1281.   #ifndef DEF_XDM_CONFIG
  1282.   #define DEF_XDM_CONFIG "/usr/lib/X11/xdm/xdm-config"
  1283.   #endif
  1284.   
  1285.   struct dmResources {
  1286.       char    *name, *class;
  1287.       int    type;
  1288. --- 68,77 ----
  1289.   #ifndef DEF_XDM_CONFIG
  1290.   #define DEF_XDM_CONFIG "/usr/lib/X11/xdm/xdm-config"
  1291.   #endif
  1292. + #ifndef CPP_PROGRAM
  1293. + #define CPP_PROGRAM "/lib/cpp"
  1294. + #endif
  1295.   
  1296.   struct dmResources {
  1297.       char    *name, *class;
  1298.       int    type;
  1299. ***************
  1300. *** 84,90 ****
  1301.   "errorLogFile",    "ErrorLogFile",    DM_STRING,    &errorLogFile,
  1302.                   "",
  1303.   "daemonMode",    "DaemonMode",    DM_BOOL,    (char **) &daemonMode,
  1304. !                 "true"
  1305.   };
  1306.   
  1307.   # define NUM_DM_RESOURCES    (sizeof DmResources / sizeof DmResources[0])
  1308. --- 87,95 ----
  1309.   "errorLogFile",    "ErrorLogFile",    DM_STRING,    &errorLogFile,
  1310.                   "",
  1311.   "daemonMode",    "DaemonMode",    DM_BOOL,    (char **) &daemonMode,
  1312. !                 "true",
  1313. ! "pidFile",    "PidFile",    DM_STRING,    &pidFile,
  1314. !                 "",
  1315.   };
  1316.   
  1317.   # define NUM_DM_RESOURCES    (sizeof DmResources / sizeof DmResources[0])
  1318. ***************
  1319. *** 101,106 ****
  1320. --- 106,113 ----
  1321.                   "",
  1322.   "xrdb",        "Xrdb",        DM_STRING,    boffset(xrdb),
  1323.                   XRDB_PROGRAM,
  1324. + "cpp",        "Cpp",        DM_STRING,    boffset(cpp),
  1325. +                 CPP_PROGRAM,
  1326.   "startup",    "Startup",    DM_STRING,    boffset(startup),
  1327.                   "",
  1328.   "reset",    "Reset",    DM_STRING,    boffset(reset),
  1329. ***************
  1330. *** 123,128 ****
  1331. --- 130,137 ----
  1332.                   DEF_SYSTEM_SHELL,
  1333.   "failsafeClient","FailsafeClient",    DM_STRING,    boffset(failsafeClient),
  1334.                   DEF_FAILSAFE_CLIENT,
  1335. + "grabTimeout",    "GrabTimeout",    DM_INT,        boffset(grabTimeout),
  1336. +                 "3",
  1337.   };
  1338.   
  1339.   # define NUM_DISPLAY_RESOURCES    (sizeof DisplayResources/\
  1340.  
  1341.  
  1342. *** /tmp/,RCSt1a04030    Fri Nov 18 16:53:09 1988
  1343. --- clients/xdm/session.c    Thu Nov 17 19:13:52 1988
  1344. ***************
  1345. *** 1,7 ****
  1346.   /*
  1347.    * xdm - display manager daemon
  1348.    *
  1349. !  * $XConsortium: session.c,v 1.7 88/10/22 21:49:29 keith Exp $
  1350.    *
  1351.    * Copyright 1988 Massachusetts Institute of Technology
  1352.    *
  1353. --- 1,7 ----
  1354.   /*
  1355.    * xdm - display manager daemon
  1356.    *
  1357. !  * $XConsortium: session.c,v 1.9 88/11/17 19:13:42 keith Exp $
  1358.    *
  1359.    * Copyright 1988 Massachusetts Institute of Technology
  1360.    *
  1361. ***************
  1362. *** 25,30 ****
  1363. --- 25,32 ----
  1364.   # include "dm.h"
  1365.   # include <X11/Xlib.h>
  1366.   # include <signal.h>
  1367. + # include <X11/Xatom.h>
  1368. + # include <setjmp.h>
  1369.   
  1370.   static int    clientPid;
  1371.   
  1372. ***************
  1373. *** 34,45 ****
  1374.       struct greet_info    greet;
  1375.       struct verify_info    verify;
  1376.       int            pid;
  1377.   
  1378.       /*
  1379.        * Step 5: Load system default Resources
  1380.        */
  1381.       LoadXloginResources (d);
  1382. !     InitGreet (d);
  1383.       for (;;) {
  1384.           /*
  1385.            * Step 6: Greet user, requesting name/password
  1386. --- 36,49 ----
  1387.       struct greet_info    greet;
  1388.       struct verify_info    verify;
  1389.       int            pid;
  1390. +     Display            *dpy, *InitGreet ();
  1391.   
  1392. +     Debug ("ManageSession %s\n", d->name);
  1393.       /*
  1394.        * Step 5: Load system default Resources
  1395.        */
  1396.       LoadXloginResources (d);
  1397. !     dpy = InitGreet (d);
  1398.       for (;;) {
  1399.           /*
  1400.            * Step 6: Greet user, requesting name/password
  1401. ***************
  1402. *** 53,58 ****
  1403. --- 57,63 ----
  1404.           else
  1405.               FailedLogin (d, &greet);
  1406.       }
  1407. +     DeleteXloginResources (d, dpy);
  1408.       CloseGreet (d);
  1409.       Debug ("Greet loop finished\n");
  1410.       /*
  1411. ***************
  1412. *** 59,65 ****
  1413.        * Step 8: Run system-wide initialization file
  1414.        */
  1415.       if (source (&verify, d->startup) != 0)
  1416. !         exit (OBEYTERM_DISPLAY);
  1417.       /*
  1418.        * Step 9: Start the clients, changing uid/groups
  1419.        *       setting up environment and running the session
  1420. --- 64,70 ----
  1421.        * Step 8: Run system-wide initialization file
  1422.        */
  1423.       if (source (&verify, d->startup) != 0)
  1424. !         SessionExit (OBEYTERM_DISPLAY);
  1425.       /*
  1426.        * Step 9: Start the clients, changing uid/groups
  1427.        *       setting up environment and running the session
  1428. ***************
  1429. *** 81,87 ****
  1430.        * Step 15: run system-wide reset file
  1431.        */
  1432.       source (&verify, d->reset);
  1433. !     exit (OBEYTERM_DISPLAY);
  1434.   }
  1435.   
  1436.   LoadXloginResources (d)
  1437. --- 86,92 ----
  1438.        * Step 15: run system-wide reset file
  1439.        */
  1440.       source (&verify, d->reset);
  1441. !     SessionExit (OBEYTERM_DISPLAY);
  1442.   }
  1443.   
  1444.   LoadXloginResources (d)
  1445. ***************
  1446. *** 90,96 ****
  1447.       char    cmd[1024];
  1448.   
  1449.       if (d->resources[0] && access (d->resources, 4) == 0) {
  1450. !         sprintf (cmd, "%s -display %s -merge %s",
  1451.                   d->xrdb, d->name, d->resources);
  1452.           Debug ("Loading resource file: %s\n", cmd);
  1453.           system (cmd);
  1454. --- 95,101 ----
  1455.       char    cmd[1024];
  1456.   
  1457.       if (d->resources[0] && access (d->resources, 4) == 0) {
  1458. !         sprintf (cmd, "%s -display %s -load %s",
  1459.                   d->xrdb, d->name, d->resources);
  1460.           Debug ("Loading resource file: %s\n", cmd);
  1461.           system (cmd);
  1462. ***************
  1463. *** 97,102 ****
  1464. --- 102,165 ----
  1465.       }
  1466.   }
  1467.   
  1468. + DeleteXloginResources (d, dpy)
  1469. + struct display    *d;
  1470. + Display        *dpy;
  1471. + {
  1472. +     XDeleteProperty(dpy, RootWindow (dpy, 0), XA_RESOURCE_MANAGER);
  1473. + }
  1474. + static jmp_buf syncJump;
  1475. + static
  1476. + syncTimeout ()
  1477. + {
  1478. +     longjmp (syncJump, 1);
  1479. + }
  1480. + SecureDisplay (d, dpy)
  1481. + struct display    *d;
  1482. + Display        *dpy;
  1483. + {
  1484. +     Debug ("SecureDisplay\n");
  1485. +     signal (SIGALRM, syncTimeout);
  1486. +     if (setjmp (syncJump)) {
  1487. +         LogError ("WARNING: display %s could not be secured\n",
  1488. +                 d->name);
  1489. +         SessionExit (ABORT_DISPLAY);
  1490. +     }
  1491. +     alarm (d->grabTimeout);
  1492. +     Debug ("Before XGrabServer\n");
  1493. +     XGrabServer (dpy);
  1494. +     if (XGrabKeyboard (dpy, DefaultRootWindow (dpy), True, GrabModeAsync,
  1495. +                GrabModeAsync, CurrentTime) != GrabSuccess)
  1496. +      {
  1497. +         alarm (0);
  1498. +         signal (SIGALRM, SIG_DFL);
  1499. +         LogError ("WARNING: keyboard on display %s could not be secured\n",
  1500. +                 d->name);
  1501. +         SessionExit (ABORT_DISPLAY);
  1502. +     }
  1503. +     Debug ("XGrabKeyboard succeeded\n");
  1504. +     alarm (0);
  1505. +     signal (SIGALRM, SIG_DFL);
  1506. +     pseudoReset (dpy);
  1507. + }
  1508. + UnsecureDisplay (d, dpy)
  1509. + struct display    *d;
  1510. + Display        *dpy;
  1511. + {
  1512. +     Debug ("Unsecure display %s\n", d->name);
  1513. +     XUngrabServer (dpy);
  1514. +     XSync (dpy, 0);
  1515. + }
  1516. + SessionExit (status)
  1517. + {
  1518. +     exit (status);
  1519. + }
  1520.   StartClient (verify, d, pidp)
  1521.   struct verify_info    *verify;
  1522.   struct display        *d;
  1523. ***************
  1524. *** 119,126 ****
  1525.           setpgrp (0, getpid ());
  1526.   #ifdef NGROUPS
  1527.   
  1528. -         setgroups (verify->ngroups, verify->groups);
  1529.           setgid (verify->groups[0]);
  1530.   #else
  1531.           setgid (verify->gid);
  1532.   #endif
  1533. --- 182,189 ----
  1534.           setpgrp (0, getpid ());
  1535.   #ifdef NGROUPS
  1536.   
  1537.           setgid (verify->groups[0]);
  1538. +         setgroups (verify->ngroups, verify->groups);
  1539.   #else
  1540.           setgid (verify->gid);
  1541.   #endif
  1542.  
  1543.  
  1544. *** /tmp/,RCSt1a04058    Fri Nov 18 17:12:58 1988
  1545. --- clients/xdm/verify.c    Thu Nov 17 19:14:01 1988
  1546. ***************
  1547. *** 1,7 ****
  1548.   /*
  1549.    * xdm - display manager daemon
  1550.    *
  1551. !  * $XConsortium: verify.c,v 1.5 88/10/20 17:37:57 keith Exp $
  1552.    *
  1553.    * Copyright 1988 Massachusetts Institute of Technology
  1554.    *
  1555. --- 1,7 ----
  1556.   /*
  1557.    * xdm - display manager daemon
  1558.    *
  1559. !  * $XConsortium: verify.c,v 1.6 88/11/17 19:13:52 keith Exp $
  1560.    *
  1561.    * Copyright 1988 Massachusetts Institute of Technology
  1562.    *
  1563. ***************
  1564. *** 49,55 ****
  1565.       char        **argv;
  1566.   
  1567.       p = getpwnam (greet->name);
  1568. !     if (!p)
  1569.           p = &joeblow;
  1570.       Debug ("Verify %s %s\n", greet->name, greet->password);
  1571.       if (strcmp (crypt (greet->password, p->pw_passwd), p->pw_passwd)) {
  1572. --- 49,55 ----
  1573.       char        **argv;
  1574.   
  1575.       p = getpwnam (greet->name);
  1576. !     if (!p || strlen (greet->name) == 0)
  1577.           p = &joeblow;
  1578.       Debug ("Verify %s %s\n", greet->name, greet->password);
  1579.       if (strcmp (crypt (greet->password, p->pw_passwd), p->pw_passwd)) {
  1580.  
  1581.  
  1582. *** /tmp/,RCSt1a04037    Fri Nov 18 16:53:46 1988
  1583. --- clients/xdm/xdm.man    Thu Nov 17 17:11:42 1988
  1584. ***************
  1585. *** 209,214 ****
  1586. --- 209,227 ----
  1587.   this behaviour may seem arbitrary, it has been empirically developed and
  1588.   works quite well on most systems.  The default values are
  1589.   5 for \fBopenDelay\fP, 5 for \fBopenRepeat\fP and 30 for \fBopenTimeout\fP.
  1590. + .IP "\fBDisplayManager.DISPLAY.grabTimeout\fP"
  1591. + To eliminate obvious security shortcomings in the X protocol,
  1592. + .I xdm
  1593. + grabs the server and keyboard while reading the name/password.  This
  1594. + resource specifies the maximum time
  1595. + .I xdm
  1596. + will wait for the grab to succeed.  The grab may fail if some other
  1597. + client has the server grabbed, or possibly if the network latencies
  1598. + are very high.  This resource has a default value of 3 seconds; you
  1599. + should be cautious when raising it as a user can be spoofed by a
  1600. + look-alike window on the display.  If the grab fails,
  1601. + .I xdm
  1602. + kills and restarts the server.
  1603.   .IP "\fBDisplayManager.DISPLAY.terminateServer\fP"
  1604.   This boolean resource specifies whether the X server should be terminated
  1605.   when a session terminates (instead of resetting it).  This option
  1606. -- 
  1607. Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
  1608. Moderator of comp.sources.x
  1609.